package com.frank.redis.service;

import com.frank.jpaBatchSave.entity.User;
import com.frank.jpaBatchSave.repository.UserRepository;
import com.frank.jpaSpecification.entity.Student1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 小石潭记
 * @date 2020/10/19 11:31
 * @Description: ${todo}
 * */


@Service
@Slf4j
public class TestService {


    @Autowired
    private UserRepository userRepository;

    @Cacheable(cacheNames = "userList")
    public List<User> getAllUser() {
        Iterable<User> all = userRepository.findAll();
        List<User> list = new ArrayList<>();
        all.forEach(singleton->{list.add(singleton);});
        log.info("user查询记录总数，{}", list.size());
        return list;
    }

}
